package nl.boelen.game.level.tiles;

import nl.boelen.game.graphics.Screen;
import nl.boelen.game.graphics.SpriteTilePosition;
import nl.boelen.game.level.Level;

public abstract class Tile {

	public static final Tile[] tiles = new Tile[256];
	public static final Tile VOID = new BasicTile(0, new SpriteTilePosition(0, 0));
	public static final Tile GRASS0 = new BasicTile(1, new SpriteTilePosition(1, 0));
	public static final Tile GRASS1 = new BasicTile(2, new SpriteTilePosition(2, 0));
	public static final Tile GRASS2 = new BasicTile(3, new SpriteTilePosition(3, 0));
	public static final Tile GRASS3 = new BasicTile(4, new SpriteTilePosition(4, 0));
	public static final Tile WATER = new BasicTile(5, new SpriteTilePosition(5, 0));
	public static final Tile MOUSEOVER = new AlphaTile(6, 0, 15);

	protected byte id;
	protected boolean hasAlpha;
	
	public Tile(int id, boolean hasAlpha) {
		this.id = (byte) id;
		this.hasAlpha = hasAlpha;
		if (tiles[id] != null) {
			throw new RuntimeException("Duplicate tile id on " + id);
		}
		tiles[id] = this;
	}

	public byte getId() {
		return id;
	}

	public abstract void render(Screen screen, Level level, int x, int y);
}
